package com.eveinfo.api.balance;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import com.eveinfo.api.AbstractApiHandler;

public class AccountBalanceHandler extends AbstractApiHandler<AccountBalanceResponse> {
	
	public AccountBalanceHandler() {
		super();
		response = new AccountBalanceResponse();
	}
	
	@Override
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
		super.startElement(uri, localName, qName, attributes);
		String value = (!localName.equals("")) ? localName : qName;
		if (value.equals("row")) {
			ApiAccountBalance balance = new ApiAccountBalance();
			balance.setAccountID(Integer.parseInt(attributes.getValue("accountID")));
			balance.setAccountKey(Integer.parseInt(attributes.getValue("accountKey")));
			balance.setBalance(Double.parseDouble(attributes.getValue("balance")));
			response.addAccountBalance(balance);
		}
	}

}
